<template>
  <!-- 订单管理 -->
  <div style="width:90%" class="order-div">
    <el-card class="box-card" style="padding-bottom:0px;min-height:80vh">
    <div class="div-1">
        <div class="div-2" @click="getmohu()" :class="{'click_color': click_color_index == 3}">
          全部订单
        </div>
        <div class="div-2" @click="getmohu(1)" :class="{'click_color': click_color_index == 2}">
          未支付
        </div>
        <div class="div-2" @click="getmohu(0)" :class="{'click_color': click_color_index == 1}">
          已支付
        </div>
      </div>
      <el-table :data="tableData" style="width: 100%" class="el-table1">
    <el-table-column type="expand">
      <template slot-scope="props">
        <el-form label-position="left" inline class="demo-table-expand">
          <el-form-item label="支付方式">
            <span>{{ props.row.orderShipping }}</span>
          </el-form-item>
          <el-form-item label="需付价格">
            <span>{{ props.row.paymentPrice }}</span>
          </el-form-item>
          <el-form-item label="下单时间">
            <span>{{ props.row.createTime }}</span>
          </el-form-item>
          <el-form-item label="商品描述">
            <span>{{ props.row.desc }}</span>
          </el-form-item>
        </el-form>
      </template>
      </el-table-column>
      <el-table-column label="订单编号" prop="orderNumber">
      </el-table-column>
      <el-table-column label="课程标题" prop="orderName">
      </el-table-column>
      <el-table-column label="描述" prop="desc">
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
            <el-button class="sb" type="text" @click="payMentByAli(scope.row)" v-if="scope.row.orderStatus == 1" style="font-size:12px">支付订单</el-button>
            <el-button class="sb" type="text" v-else style="font-size:12px">已支付</el-button>
        </template>
      </el-table-column>
    </el-table>
    </el-card>
  </div>
</template>
<script>
export default {
  name: 'OrderManagement',
  data () {
    return {
      user: {},
      click_color_index: -1,
      tableData: [],
      querybyid: {
      }
    }
  },
  mounted () {
    this.user = JSON.parse(localStorage.getItem('user')).data
    this.getUserCourse()
  },
  methods: {
    select (data) {
    },
    getUserCourse (id) {
      this.$axios
        .get('/MemberManagerPc/getUserCourse', {
          params: {
            uid: this.user.id,
            orderStatus: this.querybyid.orderStatus
          }
        })
        .then((res) => {
          if (res.data.code === 200) {
            this.tableData = res.data.data.data
          }
        })
        .catch(() => {
        // this.myMessage('error', err),
        })
    },
    // 课程购买
    buyCourse (row) {
      const forms = new FormData()
      forms.set('cid', row.courseId)
      forms.set('uid', this.user.id)
      forms.set('orderNumber', row.orderNumber)
      this.$axios.post('/CoursePc/buyCourse', forms).then(res => {
        if (res.data.code === 200) {
          if (res.data) {
            // 购买

            // window.location.reload()
            this.$message.success(res.data.data)
          } else {
            this.$message.error(res.data.data)
          }
        } else {
          this.$message.error('购买时发生错误')
        }
      })
    },
    payMentByAli (row) {
      const url = 'http://localhost:15000/alipayCoursePc/pay?orderNumber=' + row.orderNumber + '&paymentPrice=' + row.paymentPrice + '&orderName=' + row.orderName
      window.open(url)
    },
    getmohu (row) {
      this.querybyid.orderStatus = row
      this.getUserCourse()
    }
  }
}
</script>

<style scoped>
.order-div /deep/ .el-table .cell{
  font-size: 12px;
}
.demo-table-expand {
    font-size: 0;
  }
  .demo-table-expand label {
    width: 90px;
    color: #99a9bf;
  }
  .demo-table-expand .el-form-item {
    margin-right: 0;
    margin-bottom: 0;
    width: 50%;
  }
.box-card {
  margin: 0 auto;
  border-radius: 10px;
}
.div-1 {
  width: 100%;
  height: 40px;
  border-radius: 5px;
  background-color: #f5f5f5;
}
.div-2 {
  width: 100px;
  height: 40px;
  line-height: 40px;
  text-align: center;
  font-weight: bold;
  border-radius: 10px;
  float: left;
  font-size: 14px;
  cursor: pointer;
  color: #464646;
}
.click_color {
  color: rgb(63, 185, 103) !important;
}
.div-2:hover{
  color: rgb(63, 185, 103);
}
.div-3 {
  width: 100%;
  background-color: rgb(255, 255, 255);
}
.img1 {
  width: 100%;
  height: 100%;
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.div-4 {
  width: 100%;
  height: 500px;
  /* background-color: red; */
}
.div4-1 {
  width: 100%;
  height: 50px;
  background-color: rgb(245, 248, 250);
  border-radius: 10px;
  font-size: 16px;
}
.div4-1 p {
  width: 180px;
  height: 30px;
  margin-left: 16px;
  padding-top: 12px;
  font-size: 16px;
}
.div4-2 {
  width: 100%;
  height: 100px;
  /* background-color: rgb(36, 137, 205); */
  /* 边框变黑1px */
  border-bottom: 1px solid rgb(210, 211, 212);
}
.div4-2-1 {
  width: 100px;
  height: 100px;
  float: left;
  margin-top: 20px;
}
.div4-2-2 {
  width: 200px;
  height: 100px;
  float: left;
  font-size: 16px;
  margin-top: 10px;
}
.div4-2-3 {
  width: 150px;
  height: 100px;
  float: left;
}
.div4-2-4 {
  width: 150px;
  height: 100px;
  float: left;
  margin-left: 80px;
}
.div4-2-5 {
  width: 150px;
  height: 100px;
  float: left;
}
.div4-2-5 p {
  width: 100px;
  margin-left: 10px;
  text-align: left;
  margin-top: 32px;
  font-size: 16px;
}
.div4-2-1-1 {
  width: 100px;
  height: 60px;
  margin: 0 auto;
  margin-top: 20px;
}
.div4-2-8 {
  width: 100px;
  height: 100px;
  float: left;
  margin-top: 15px;
}
.div4-2-2 p {
  width: 90%;
  height: 40px;
  text-align: left;
  margin: 0 auto;
  margin-top: 30px;
  overflow: hidden;
  font-size: 16px;
}
.div4-2-3 p {
  width: 90%;
  height: 40px;
  text-align: left;
  margin: 0 auto;
  margin-top: 40px;
  font-size: 16px;
}
.div4-2-4 p {
  width: 90%;
  height: 40px;
  text-align: left;
  margin: 0 auto;
  margin-top: 40px;
  font-size: 16px;
}
.div4-2-4-span {
  width: 90%;
  height: 40px;
  text-align: left;
  margin: 0 auto;
  margin-top: 40px;
  font-size: 16px;
}
.div-4-box {
  width: 100%;
  height: 100px;
  border-radius: 10px;
  margin-top: 20px;
}
.div33 {
  width: 100%;
  height: 24px;
  border: 1px solid rgb(245, 248, 250);
  /* border-bottom: 0.1px solid rgb(144,147,153); */
  font-weight: bold;
  margin-top: 10px;
}
.div33-1 {
  width: 40%;
  height: 100%;
  float: left;
}
.div33-2 {
  width: 20%;
  height: 100%;
  float: left;
}
.div33-3 {
  width: 20%;
  height: 100%;
  float: left;
}
.div33-1-p {
  width: 100%;
  height: 100%;
  font-size: 12px;
  text-align: left;
  margin-top: 4px;
  margin-left: 10px;
  color: rgb(161, 169, 178);
}
  .el-button--text {
    border-color: transparent;
    color: #3d3d3d;
    background: 0 0;
    padding-left: 0;
    padding-right: 0;
}
  .sb:hover{
    color: #7ab2fa;
  }
</style>
